// @ts-ignore
import { request } from '@umijs/max';

// 创建会话
export async function conversations(body: any) {
  return request<{
    data: API.ReqResult;
  }>(`/api/knowledge_bases/conversations`, {
    method: 'POST',
    data: body,
  });
}
// 删除会话
export async function delConver(id: any) {
  return request<{
    code: number;
    data: API.ReqResult;
  }>(`/api/knowledge_bases/conversations/${id}`, {
    method: 'DELETE',
  });
}

// 创建对话信息
export async function createMessages(body: any) {
  return request<{
    data: API.ReqResult;
  }>(`/api/knowledge_bases/messages`, {
    method: 'POST',
    data: body,
  });
}
// 获取会话列表
export async function getConversationsList(params: any, options?: { [key: string]: any }) {
  return request<{
    data: API.ReqResult;
  }>('/api/knowledge_bases/conversations', {
    method: 'GET',
    params,
    ...(options || {}),
  });
}
// 获取会话信息列表
export async function getMessages(params: any, options?: { [key: string]: any }) {
  return request<{
    data: API.ReqResult;
  }>('/api/knowledge_bases/messages', {
    method: 'GET',
    params,
    ...(options || {}),
  });
}

// 打字机对话
export async function messages_stream(body: any) {
  return request<{
    data: API.ReqResult;
    responseType: 'stream';
  }>(`/api/knowledge_bases/messages_stream`, {
    method: 'POST',
    data: body,
  });
}

// 打字机对话
export async function messages_comet(body: any) {
  return request<{
    data: API.ReqResult;
    responseType: 'stream';
  }>(`/api/knowledge_bases/messages_comet`, {
    method: 'POST',
    data: body,
  });
}
// 获取打字机对话-轮询内容
export async function pollingMsg(params: any, options?: { [key: string]: any }) {
  return request<{
    data: API.ReqResult;
  }>('/api/knowledge_bases/messages/' + params.id, {
    method: 'GET',
    ...(options || {}),
  });
}
